package singleton;

/**
 * @author wcj
 * @Date 2021/6/19 20:02
 * @Version 1.0
 */
public class LazySingleton {

    private static LazySingleton singleton = null;

    private LazySingleton() {
    }

    /**
     * 懒汉式写法的单例模式，线程不安全，可以通过增加synchronized来保证其线程安全
     *
     * @return
     */
    public static LazySingleton getSingleton() {
        if (singleton == null) {
            singleton = new LazySingleton();
        }
        return singleton;
    }
}
